home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / pack / bytekiller / bytekiller.s next >
Text File  |  1980-01-03  |  41KB  |  1,176 lines

  1. ;START
  2.                     OPT     D+
  3.  
  4. * -            ByteKiller cruncher written by Lord Blitter             - *
  5. * -                 and improved by Cath of Fury 1992                  - *
  6.  
  7. * -                     Equates and defines needed                     - *
  8.  
  9. LF                  equ     10
  10. ESC                 equ     $1B
  11. color0              equ     $00000180
  12. _custom             equ     $00dff000
  13. Relative            equ     1   ; set this and code will be pc-relative,ha ha
  14. _LVOFlush           equ     -360
  15.  
  16. * -                               Macros                               - *
  17.  
  18. Write               macro
  19.                     movem.l d0-d7/a0-a6,-(sp)
  20.                     move.l  #\1,d2
  21.                     move.l  #l_\1,d3                 ; length of message
  22.                     jsr     _Write(pc)
  23.                     movem.l (sp)+,d0-d7/a0-a6
  24.                     endm
  25.  
  26. length              macro
  27. l_\1                equ     *-\1
  28.                     even
  29.                     endm
  30.  
  31. ptr                 macro
  32.                     dc.l   \1
  33.                     dc.w   l_\1
  34.                     endm
  35.  
  36. Found               macro
  37.                     move.l  #\1,d2
  38.                     move.l  #l_\1,d3
  39.                     bra     KnownType
  40.                     endm
  41.  
  42. * -                         Code starts here                           - *
  43.  
  44.                     section cruncher,code
  45.  
  46.                     lea     DosLibName,a1
  47.                     CALLEXEC OldOpenLibrary            ; open dos.library
  48.                     move.l  d0,DosBase
  49.                     beq.s   QuitOnError
  50.  
  51.                     bra.s   StartOfProgram             ; jump to program
  52.  
  53. QuitOnError         clr.l   _custom+color0             ; Bye bye
  54.                     moveq.l #-1,d0
  55.                     rts     
  56. _Write 
  57.                     move.l  InitOutput,d1
  58.                     CALLDOS Write
  59.                     rts
  60.  
  61. StartOfProgram
  62.                     CALLDOS Output                      ; get output handle
  63.                     move.l  d0,InitOutput
  64.                     CALLDOS Input                       ; get input handle
  65.                     move.l  d0,InitInput
  66.  
  67.                     Write StartupText
  68.  
  69.                     Write FreeChipMem
  70.  
  71.                     move.l   #MEMF_CHIP|MEMF_LARGEST,d1 ; Get largest available
  72.                     CALLEXEC AvailMem                   ; chip memory size
  73.                     divu     #1024,d0                   ; convert from  K to MB
  74.                     and.l    #$0000ffff,d0
  75.                     bsr      NumberToString
  76.                     Write    FreeFastMem
  77.  
  78.                     move.l   #MEMF_FAST|MEMF_LARGEST,d1 ; Get largest available
  79.                     CALLEXEC AvailMem                   ; fast memory size
  80.                     divu     #1024,d0                   ; convert from K To MB
  81.                     and.l    #$0000ffff,d0
  82.                     bsr      NumberToString
  83.  
  84. InputWorkSpace
  85.                     Write   AllocateWork
  86.  
  87.                     bsr     WipeBuffer                  ; Clr input buffer
  88.  
  89.                     moveq.l #4,d3                       ; 4 bytes + 1 for LF
  90.                     bsr     ReadIn                      ; Read in from stdin
  91.                     cmp.l   #1,d0
  92.                     bls.s   InputWorkSpace
  93.  
  94.                     subq.l  #1,d0                       ; length of string
  95.                     move.l  #Buffer,a0                  ; ptr to buffer
  96.                     add.l   d0,a0                       ; ptr to end of string
  97.                     move.b  -(a0),d1                    ; fetch char
  98.                     subq.l  #1,d0                       ; sub length of string
  99.                     bsr     StringToNum
  100.                     cmp.b   #10,d1
  101.                     bcc.s   InputWorkSpace
  102.  
  103.                     moveq.l #0,d2
  104.                     move.b  d1,d2
  105.                     tst.b   d0
  106.                     beq.s   lbC00010A
  107.  
  108.                     move.b  -(a0),d1
  109.                     subq.l  #1,d0
  110.                     bsr     StringToNum
  111.                     cmp.b   #10,d1
  112.                     bcc.s   InputWorkSpace
  113.  
  114.                     and.w   #15,d1
  115.                     mulu    #10,d1
  116.                     add.w   d1,d2
  117.                     tst.b   d0
  118.                     beq.s   lbC00010A
  119.  
  120.                     move.b  -(a0),d1
  121.                     bsr     StringToNum
  122.                     cmp.b   #10,d1
  123.                     bcc     InputWorkSpace
  124.  
  125.                     and.w   #15,d1
  126.                     mulu    #100,d1
  127.                     add.w   d1,d2
  128.                     tst.w   d2
  129.                     beq     InputWorkSpace
  130.  
  131. lbC00010A           moveq.l #0,d0
  132.                     subq.w  #1,d2
  133. lbC00010E           add.l   #$00000400,d0
  134.                     dbra    d2,lbC00010E
  135.  
  136.                     move.l   d0,LengthToAlloc
  137.                     move.l   #MEMF_PUBLIC|MEMF_CLEAR,d1
  138.                     move.l   LengthToAlloc,d0
  139.                     CALLEXEC AllocMem
  140.                     move.l   d0,AllocMem
  141.                     beq      InputWorkSpace
  142.  
  143.                     add.l    #$00000080,d0
  144.                     move.l   d0,FileBuffer
  145. ReadFileName
  146.                     Write    LoadName
  147.  
  148.                     moveq.l  #$1E,d3                       ; Length
  149.                     bsr      ReadIn
  150.                     cmp.l    #1,d0
  151.                     bls.s    ReadFileName
  152.  
  153.                     subq.l   #1,d0
  154.                     lea      Buffer,a0
  155.                     add.l    d0,a0
  156.                     clr.b    (a0)
  157.                     lea      Buffer,a0
  158.                     cmp.b    #'-',(a0)
  159.                     bne.s    NotCliCommand
  160.  
  161.                     addq.l   #1,a0
  162.                     move.l   a0,d1
  163.                     moveq.l  #0,d2
  164.                     move.l   InitOutput,d3
  165.                     CALLDOS  Execute
  166.                     bra.s    ReadFileName
  167.  
  168. NotCliCommand       cmp.l    #'exit',(a0)
  169.                     beq      FreeAndQuit
  170.   
  171.                     move.l   #Buffer,d1
  172.                     move.l   #$000003ED,d2
  173.                     CALLDOS  Open
  174.                     move.l   d0,_OurLock
  175.                     bne.s    FileOpenOk             ; Opened file Ok
  176.                     Write    FileNotFound
  177.                     bra      ReadFileName
  178. FileOpenOk 
  179.                     move.l   _OurLock,d1
  180.                     move.l   FileBuffer,d2
  181.                     move.l   LengthToAlloc,d3
  182.                     sub.l    #$00000080,d3    ; make sure we dont overrun buffer
  183.                     CALLDOS  Read
  184.                     move.l   d0,ActualLength
  185.                     move.l   _OurLock,d1
  186.                     CALLDOS Close
  187.  
  188.                     move.l   LengthToAlloc,d0
  189.                     sub.l    #$00000080,d0
  190.  
  191.                     cmp.l    ActualLength,d0
  192.                     bhi      ReadOk           ; Did we read nothing or overrun
  193.  
  194.                     Write    FileOverrun
  195.                     bra      ReadFileName
  196. ReadOk
  197.                     move.l   FileBuffer,a0
  198.     
  199. ; Determine the type of file if possible.
  200.  
  201.                     cmp.l    #$000003f3,(a0)
  202.                     bne      FileIsNotExec
  203.  
  204.                     Write    Warning
  205. FileIsNotExec
  206.                     Write    FileTypeIs
  207.  
  208.                     lea      WhatIs,a1
  209. ContinueSearch
  210.                     clr.l    d0
  211.                     move.w   (a1)+,d0        ; fetch offset/control word
  212.                     cmp.w    #-1,d0        ; is it end of list
  213.                     beq.s    UnknownType    ; branch if so
  214.                     move.l   (a1)+,a2        ; fetch Compare longword
  215.                     cmp.w    #-2,d0             ; Is a search150 control
  216.                     beq.s    DoSearch           ; Yup
  217.                     cmp.l    (a0,d0.w),a2    ; compare it against file
  218.                     beq.s    FoundMatch        ; branch if Matched
  219. NotFound
  220.                     add.l    #6,a1        ; next record
  221.                     bra.s    ContinueSearch    ; continue
  222. DoSearch
  223.                     move.l   #$150,d0
  224. SearchLoop
  225.                     cmp.l    (a0,d0.w),a2
  226.                     beq.s    FoundMatch
  227.                     sub.w    #2,d0
  228.                     bne.s    SearchLoop
  229.                     bra.s    NotFound                    
  230. FoundMatch
  231.                     move.l   (a1)+,d2        ; Fetch ptr to string
  232.                     clr.l    d3
  233.                     move.w   (a1)+,d3        ; fetch length of string
  234.                     bra.s    KnownType        ; write it out
  235.  
  236. UnknownType
  237.                     Found    DataAbsFile
  238. KnownType
  239.                     movem.l  d0-d7/a0-a6,-(sp)
  240.                     jsr      _Write(pc)
  241.                     movem.l  (sp)+,d0-d7/a0-a6
  242.  
  243. AlreadyDeterminedType
  244.                     Write    OriginalLength
  245.                     move.l   ActualLength,d0    ; Number to convert
  246.                     bsr      NumberToString
  247. ReadScanWidth
  248.                     Write    OffsetLength
  249.                     move.l   #OffsetLength,d2
  250. _Length
  251.                     bsr      WipeBuffer
  252.                     moveq.l  #5,d3              ; length to read
  253.                     bsr      ReadIn
  254.                     cmp.l    #1,d0
  255.                     bls.s    ReadScanWidth
  256.  
  257.                     moveq.l  #4,d0
  258.                     bsr      ConvertNumber
  259.                     cmp.w    #$1000,d0          ; Number to low (1.3 machines)
  260.                     ble.s    CheckLowerBound
  261.                     Write    TooHigh
  262.                     bra.s    ReadScanWidth
  263. CheckLowerBound
  264.                     cmp.w    #$5,d0             ; User being funny
  265.                     bhi.s    ScanWidthOk
  266.                     Write    WantLongerFile
  267.                     bra      ReadScanWidth
  268. ScanWidthOk 
  269.                     bclr     #0,d0
  270.                     move.l   d0,ScanWidth
  271.  
  272. ;                   CALLEXEC Forbid
  273.                     bsr      CrunchFile
  274. ;                   CALLEXEC Permit
  275.  
  276.                     move.l   AllocMem,a0
  277.                     move.l   LengthOfPacked,(a0)
  278.  
  279.                     Write    Won
  280.  
  281.                     move.l  ActualLength,a1
  282.                     move.l  LengthOfPacked,a2
  283.                     sub.l   a2,a1
  284.                     move.l  a1,d0
  285.                     bsr     NumberToString
  286.  
  287.  
  288.                   ifne 0
  289.                     move.l  DosBase,a6
  290.                     lea     lbL00077C(pc),a5
  291.                     moveq.l #5,d1
  292. lbC00029A           move.w  (a5)+,d0
  293.                     bsr     lbC00056A
  294.                     dbra    d1,lbC00029A
  295.                   endc
  296.  
  297.  
  298.                     Write   PackedLength
  299.                     move.l  LengthOfPacked,d0
  300.                     add.l   #12,d0               ; account for bss
  301.                     bsr     NumberToString       ; write length of packed data
  302. ExecOrDataFile
  303.                     Write   ExecOrData
  304.                     moveq.l #30,d3               ; length to read
  305.                     bsr     ReadIn
  306.                     cmp.l   #1,d0                ; Didn't enter anything
  307.                     bls.s   ExecOrDataFile
  308.  
  309.                     lea     Buffer,a0
  310.                     cmp.b   #'d',(a0)            ; Was a 'd' entered
  311.                     beq     DataFile
  312.  
  313.                     cmp.b   #'e',(a0)            ; was an 'e' entered
  314.                     bne.s   ExecOrDataFile
  315.  
  316.                     move.l  LengthOfPacked,d0
  317.                     add.l   #292,d0
  318.                     cmp.l   ActualLength,d0
  319.                     blo.s   GetLocateAt
  320.                     Write   FileHeadLonger
  321.  
  322. GetLocateAt
  323.                     Write   LocateFileAt
  324.                     moveq.l #$1E,d3              ; Length To Read
  325.                     bsr     ReadIn
  326.                     cmp.l   #1,d0
  327.                     bls.s   GetLocateAt
  328.  
  329.                     moveq.l #5,d0                ; length of number to convert
  330.                     bsr     ConvertNumber
  331.                     move.l  d0,LocateAddr
  332.                     move.l  d0,a1
  333.                     jsr     TypeMemRoutine
  334. ReadJumpAddr
  335.                     Write   JumpInAddr
  336.                     moveq.l #30,d3              ; length to read
  337.                     bsr     ReadIn
  338.                     cmp.l   #1,d0
  339.                     bls.s   ReadJumpAddr
  340.  
  341.                     moveq.l #5,d0               ; length of number to convert
  342.                     bsr     ConvertNumber
  343.                     move.l  d0,JumpAddr
  344.                     move.l  d0,a1
  345.                     jsr     TypeMemRoutine
  346.  
  347.                     move.l  AllocMem,a0
  348.                     add.l   LengthOfPacked,a0
  349.                     add.l   #12,a0              ; add on bss bit
  350.                     move.l  a0,a1
  351.                     add.l   #$0000010C,a1
  352.                     move.l  a1,a2
  353.                     move.l  LengthOfPacked,d0
  354.                     add.l   #12,d0
  355.                     move.l  d0,d1
  356.                     swap    d1
  357.                     bra.s   lbC0003B6
  358.  
  359. lbC0003B4           move.b  -(a0),-(a1)
  360. lbC0003B6           dbra    d0,lbC0003B4
  361.  
  362.                     dbra    d1,lbC0003B4
  363.  
  364.                     lea     Decruncher,a0
  365.                     move.l  AllocMem,a1
  366.                     move.w  #$010B,d0
  367. lbC0003CE           move.b  (a0)+,(a1)+
  368.                     dbra    d0,lbC0003CE
  369.  
  370.                     move.l  a2,d0
  371.                     sub.l   AllocMem,d0
  372.                     sub.l   #$00000024,d0
  373.                     move.l  d0,d1
  374.                     divu    #4,d1
  375.                     swap    d1
  376.                     tst.b   d1
  377.                     beq.s   lbC0003FC
  378.  
  379.                     addq.l  #2,d0
  380.                     move.l  d0,d1
  381.                     divu    #4,d1
  382.                     swap    d1
  383. lbC0003FC
  384.                     swap    d1
  385.                     move.l  AllocMem,a0
  386.                     move.l  d1,Length1(a0)           ; $14
  387.                     move.l  d1,Length2(a0)           ; $20
  388.                     add.l   #$00000024,d0
  389.                     move.l  d0,a2
  390.                     add.l   a0,a2
  391.                     add.l   #$00000018,d0
  392.                     sub.l   #12,d0
  393.                     move.l  d0,LengthOfPacked
  394.  
  395.                     lea     RelocBSSData,a0
  396.                     move.l  a2,a1
  397.                     moveq.l #LengthBSS,d0
  398. lbC000432           move.b  (a0)+,(a1)+
  399.                     dbra    d0,lbC000432
  400.  
  401.                     move.l  AllocMem,a0
  402.                     move.l  LocateAddr,Reloc1(a0)   ; Fill in LocateAddr (2a)
  403.                     move.l  JumpAddr,Reloc2(a0)     ; Fill in JumpAddr ($d0)
  404. DataFile
  405.                     move.l  LengthOfPacked,d0
  406.                     cmp.l   ActualLength,d0
  407.                     blo.s   SaveFile
  408.                     Write   FileLonger
  409. SaveFile
  410.                     Write   SaveFileName
  411.                     moveq.l #$1E,d3                 ; Length to input
  412.                     bsr     ReadIn
  413.                     cmp.l   #1,d0
  414.                     bls.s   DataFile                ; Re-Read filename
  415.  
  416.                     subq.l  #1,d0
  417.                     lea     Buffer,a0
  418.                     add.l   d0,a0
  419.                     clr.b   (a0)
  420.                     lea     Buffer,a0
  421.                     cmp.b   #'-',(a0)
  422.                     bne.s   IsItExit                ; Is it a command
  423.  
  424.                     addq.l  #1,a0
  425.                     move.l  a0,d1
  426.                     moveq.l #0,d2
  427.                     move.l  InitOutput,d3
  428.                     CALLDOS Execute
  429.                     bra     DataFile
  430.  
  431. IsItExit            cmp.l   #'exit',(a0)
  432.                     beq.s   FreeAndQuit
  433.  
  434.                     move.l  #Buffer,d1              ; FileName
  435.                     move.l  #MODE_NEWFILE,d2        ; File Mode
  436.                     CALLDOS Open
  437.                     move.l  d0,_OurLock
  438.                     move.l  d0,d1
  439.                     move.l  AllocMem,d2         ; Address of crunched data
  440.                     move.l  LengthOfPacked,d3   ; Length of file
  441.                     add.l   #12,d3              ; Add BSS bit
  442.                     CALLDOS Write
  443.                     cmp.l   #-1,d0              ; Was there an error
  444.                     beq     DataFile            ; Yup
  445.  
  446.                     move.l   _OurLock,d1         ; Close output file
  447.                     CALLDOS  Close
  448. FreeAndQuit
  449.                     move.l   LengthToAlloc,d0    ; Free memory
  450.                     move.l   AllocMem,a1
  451.                     CALLEXEC FreeMem
  452.                     move.l   DosBase,a1          ; close dos library
  453.                     CALLEXEC CloseLibrary
  454.                     clr.l    d0
  455.                     rts                        ; quit
  456.  
  457. ConvertNumber       movem.l  d1-d7/a0-a6,-(sp)
  458.                     move.l   d0,d3
  459.                     clr.l    d0
  460.                     clr.l    d1
  461.                     clr.l    d2
  462.                     lea      Buffer,a0
  463. DoConv              move.b   (a0)+,d1
  464.                     bsr      StringToNum
  465.                     and.w    #15,d1
  466.                     lsl.l    #4,d2
  467.                     or.w     d1,d2
  468.                     cmp.b    #10,(a0)
  469.                     beq.s    lbC00053E
  470.  
  471.                     dbra     d3,DoConv
  472.  
  473. lbC00053E           move.l   d2,d0
  474.                     movem.l  (sp)+,d1-d7/a0-a6
  475.                     rts     
  476.  
  477. StringToNum         movem.l  d0/a0,-(sp)
  478.                     moveq.l  #0,d0
  479.                     lea      ConvertStr,a0
  480. lbC000552           cmp.b    0(a0,d0.l),d1
  481.                     beq.s    lbC000562
  482.  
  483.                     addq.l   #1,d0
  484.                     cmp.l    #$00000010,d0
  485.                     bcs.s    lbC000552
  486.  
  487. lbC000562           move.l   d0,d1
  488.                     movem.l  (sp)+,d0/a0
  489.                     rts     
  490.  
  491. lbC00056A           movem.l  d0-d7/a0-a6,-(sp)
  492.                     lea      Buffer,a0
  493.                     addq.l   #6,a0
  494.                     lea      ConvertStr,a1
  495.                     move.b   #$20,-(a0)
  496.                     moveq.l  #4,d2
  497. lbC000586           move.l   d0,d1
  498.                     and.l    #15,d1
  499.                     move.b   0(a1,d1.l),-(a0)
  500.                     lsr.l    #4,d0
  501.                     dbra     d2,lbC000586
  502.  
  503.                     move.b   #$24,(a0)
  504.                     move.l   InitOutput,d1        ; write out buffer
  505.                     move.l   #Buffer,d2
  506.                     moveq.l  #6,d3                ; length of string
  507.                     CALLDOS  Write
  508.                     movem.l  (sp)+,d0-d7/a0-a6
  509.                     rts     
  510.  
  511. NumberToString      movem.l  d0-d7/a0-a6,-(sp)
  512.                     lea      Buffer,a0
  513.                     add.l    #10,a0
  514.                     lea      ConvertStr,a1
  515.                     move.b   #10,-(a0)
  516.                     moveq.l  #8,d2
  517. lbC0005D0           move.l   d0,d1
  518.                     and.l    #15,d1
  519.                     move.b   0(a1,d1.l),-(a0)
  520.                     lsr.l    #4,d0
  521.                     dbra     d2,lbC0005D0
  522.  
  523.                     move.b   #$24,(a0)
  524.                     move.l   InitOutput,d1       ; write out buffer
  525.                     move.l   #Buffer,d2
  526.                     moveq.l  #10,d3              ; Length of string
  527.                     CALLDOS  Write
  528.                     movem.l  (sp)+,d0-d7/a0-a6
  529.                     rts     
  530.  
  531. CrunchFile          move.l   FileBuffer,a0
  532.                     move.l   FileBuffer,a1
  533.                     add.l    ActualLength,a1
  534.                     move.l   AllocMem,a2
  535.                     move.l   #0,(a2)+
  536.                     move.l   ActualLength,(a2)+
  537.                     move.l   #0,(a2)+
  538.                     moveq.l  #1,d2
  539.                     clr.w    d1
  540.                     clr.l    d7
  541. lbC00062E           bsr.s    lbC000670
  542.                     tst.b    d0
  543.                     beq.s    lbC000640
  544.  
  545.                     addq.w   #1,d1
  546.                     cmp.w    #$0108,d1
  547.                     bne.s    lbC000640
  548.  
  549.                     bsr      lbC000788
  550. lbC000640           cmp.l    a0,a1
  551.                     bgt.s    lbC00062E
  552.  
  553.                     bsr      lbC000788
  554.                     bsr      lbC0007C4
  555.                     move.l   a2,d0
  556.                     sub.l    AllocMem,d0
  557.                     sub.l    #12,d0
  558.                     move.l   d0,LengthOfPacked
  559.                     move.l   AllocMem,a3
  560.                     move.l   d7,8(a3)
  561.                     move.l   d0,(a3)
  562.                     rts     
  563.  
  564. lbC000670           move.l   a0,a3
  565.                     add.l    ScanWidth,a3
  566.                     cmp.l    a1,a3
  567.                     ble.s    lbC00067E
  568.  
  569.                     move.l   a1,a3
  570. lbC00067E           moveq.l  #1,d5
  571.                     move.l   a0,a5
  572.                     addq.w   #1,a5
  573. lbC000684           move.b   (a0),d3
  574.                     move.b   1(a0),d4
  575. lbC00068A           cmp.b    (a5)+,d3
  576.                     bne.s    lbC000692
  577.  
  578.                     cmp.b    (a5),d4
  579.                     beq.s    lbC000698
  580.  
  581. lbC000692           cmp.l    a5,a3
  582.                     bgt.s    lbC00068A
  583.  
  584.                     bra.s    lbC0006F4
  585.  
  586. lbC000698           subq.w   #1,a5
  587.                     move.l   a0,a4
  588. lbC00069C           move.b   (a4)+,d3
  589.                     cmp.b    (a5)+,d3
  590.                     bne.s    lbC0006A6
  591.  
  592.                     cmp.l    a5,a3
  593.                     bgt.s    lbC00069C
  594.  
  595. lbC0006A6           move.l   a4,d3
  596.                     sub.l    a0,d3
  597.                     subq.l   #1,d3
  598.                     cmp.l    d3,d5
  599.                     bge.s    lbC0006F0
  600.  
  601.                     move.l   a5,d4
  602.                     sub.l    a0,d4
  603.                     sub.l    d3,d4
  604.                     subq.w   #1,d4
  605.                     cmp.l    #4,d3
  606.                     ble.s    lbC0006D0
  607.  
  608.                     moveq.l  #6,d6
  609.                     cmp.l    #$00000101,d3
  610.                     blt.s    lbC0006CE
  611.  
  612.                     move.w   #$0100,d3
  613. lbC0006CE           bra.s    lbC0006D6
  614.  
  615. lbC0006D0           move.w   d3,d6
  616.                     subq.w   #2,d6
  617.                     lsl.w    #1,d6
  618. lbC0006D6           lea      lbL000754(pc),a6
  619.                     cmp.w    0(a6,d6.w),d4
  620.                     bge.s    lbC0006F0
  621.  
  622.                     move.l   d3,d5
  623.                     move.l   d4,lbL00074E
  624.                     move.b   d6,lbW000752
  625.  
  626. lbC0006F0           cmp.l    a5,a3
  627.                     bgt.s    lbC000684
  628.  
  629. lbC0006F4           cmp.l    #1,d5
  630.                     beq.s    lbC000740
  631.  
  632.                     bsr.s    lbC000788
  633.                     move.b   lbW000752(pc),d6
  634.                     move.l   lbL00074E(pc),d3
  635.                     move.w   d3,_custom+color0
  636.                     move.w   8(a6,d6.w),d0
  637.                     bsr.s    lbC0007B6
  638.                     move.w   $0010(a6,d6.w),d0
  639.                     beq.s    lbC000728
  640.  
  641.                     move.l   d5,d3
  642.                     subq.w   #1,d3
  643.                     bsr.s    lbC0007B6
  644. lbC000728           move.w   $0018(a6,d6.w),d0
  645.                     move.w   $0020(a6,d6.w),d3
  646.                     bsr.s    lbC0007B6
  647.                     addq.w   #1,$0028(a6,d6.w)
  648.                     add.l    d5,a0
  649.                     clr.b    d0
  650.                     rts     
  651.  
  652. lbC000740           move.b   (a0)+,d3
  653.                     moveq.l  #8,d0
  654.                     bsr.s    lbC0007B6
  655.                     moveq.l  #1,d0
  656.                     rts     
  657.  
  658.  
  659.  
  660. lbC000788           tst.w    d1
  661.                     beq.s    lbC0007A2
  662.  
  663.                     move.w   d1,d3
  664.                     clr.w    d1
  665.                     cmp.w    #9,d3
  666.                     bge.s    lbC0007A4
  667.                     addq.w   #1,lbW000784
  668.                     subq.w   #1,d3
  669.                     moveq.l  #5,d0
  670.                     bra.s    lbC0007B6
  671.  
  672. lbC0007A2           rts     
  673.  
  674. lbC0007A4
  675.                     addq.w   #1,lbW000786
  676.                     sub.w    #9,d3
  677.                     or.w     #$0700,d3
  678.                     moveq.l  #11,d0
  679. ;                   nop     
  680. lbC0007B6           subq.w   #1,d0
  681. lbC0007B8           lsr.l    #1,d3
  682.                     roxl.l   #1,d2
  683.                     bcs.s    lbC0007C6
  684.  
  685.                     dbra     d0,lbC0007B8
  686.  
  687.                     rts     
  688.  
  689. lbC0007C4           clr.w    d0
  690. lbC0007C6           move.l   d2,(a2)+
  691.                     eor.l    d2,d7
  692.                     moveq.l  #1,d2
  693.                     dbra     d0,lbC0007B8
  694.  
  695.                     rts     
  696.  
  697. WipeBuffer          movem.l  d0/a0,-(sp)
  698.                     lea      Buffer,a0
  699.                     moveq.l  #14,d0
  700. Clrbuffer           clr.w    (a0)+
  701.                     dbra     d0,Clrbuffer
  702.  
  703.                     movem.l  (sp)+,d0/a0
  704.                     rts     
  705. TypeMemRoutine
  706.                     CALLEXEC TypeOfMem
  707.                     tst.l    d0
  708.                     bne.s    MemoryAvailable
  709.  
  710.                     Write    NoMemoryThere
  711.                     bra      EndMemRoutine
  712.  
  713. ; This next bit determines what type of memory is available at the
  714. ; address specified.
  715.  
  716. MemoryAvailable
  717.                     Write    TypeOfMem
  718.                     btst     #0,d0
  719.                     beq.s    NotPublic
  720.                     Write    IsPublicMem
  721.                     bra      ChipOrFast
  722. NotPublic
  723.                     btst     #8,d0
  724.                     beq.s    NotLocal
  725.                     Write    IsLocalMem
  726.                     bra      ChipOrFast
  727. NotLocal
  728.                     btst     #9,d0
  729.                     beq.s    ChipOrFast
  730.                     Write    Is24BitMem
  731. ChipOrFast
  732.                     btst     #1,d0
  733.                     beq.s    NotChipMem
  734.                     Write    IsChipMem
  735.                     bra.s    EndMemRoutine
  736. NotChipMem
  737.                     btst     #2,d0
  738.                     beq.s    NotFastOrChip
  739.                     Write    IsFastMem
  740.                     bra.s    EndMemRoutine
  741. NotFastOrChip
  742.                     Write    WowWhatKindOfRam
  743. EndMemRoutine
  744.                     rts
  745. ReadIn
  746.                     move.l   InitInput,d1
  747.                     move.l   #Buffer,d2
  748.                     CALLDOS  Read
  749.     ifeq    1
  750.                     movem.l  d0-d7/a0-a6,-(sp)
  751.  
  752.                     move.l   InitInput,d1
  753.                     move.l   #100,d2
  754.                     CALLDOS  WaitForChar
  755.                     cmp.l    #0,d0
  756.                     beq.s    LeaveRead
  757.  
  758.                     move.l   InitInput,d1
  759.                     move.l   #Trebor,d2
  760.                     move.l   #100,d3
  761.                     CALLDOS  Read
  762. LeaveRead
  763.                     movem.l  (sp)+,d0-d7/a0-a6
  764.     endc
  765.                     rts
  766.  
  767. Trebor              dcb.l    20
  768.  
  769. lbL00074E           dc.l     0
  770. lbW000752           dc.w     0
  771. lbL000754           dc.l     $01000200
  772.                     dc.l     $04001000
  773.                     dc.l     $00080009
  774.                     dc.l     $000A000C
  775.                     dc.l     0
  776.                     dc.l     8
  777.                     dc.l     $00020003
  778.                     dc.l     $00030003
  779.                     dc.l     $00010004
  780.                     dc.l     $00050006
  781. lbL00077C           dc.l     0
  782.                     dc.l     0
  783. lbW000784           dc.w     0
  784. lbW000786           dc.w     0
  785.  
  786.     section     ByteKillerData,data
  787.  
  788.                     ; This is the decruncher for the executable option
  789.  
  790. LengthOfPacked      dc.l     0
  791.  
  792. Decruncher
  793.                     dc.l     $000003F3        ; Hunk Header
  794.                     dc.l     0
  795.                     dc.l     1                ; number of hunks (2)
  796.                     dc.l     0
  797.                     dc.l     1                ; ? (1)
  798. Length1             equ      *-Decruncher
  799.                     dc.l     $3b              ; length of hunk
  800.                     dc.l     0
  801.                     dc.l     $000003E9        ; Hunk code
  802. Length2             equ      *-Decruncher
  803.                     dc.l     $3B              ; Hunk Length
  804.  
  805.        ; Start of Code Check longword
  806.  
  807.                     dc.l     $41FA00E6        ; lea +0e6,a0
  808.                     dc.w     $43F9            ; lea LoadAddr,a1
  809. Reloc1              equ      *-Decruncher
  810.                     dc.l     $00040000
  811.                     dc.w     $2018
  812.                     dc.l     $22182A18
  813.                     dc.l     $2449D1C0
  814.                     dc.l     $D5C12020
  815.                     dc.l     $B185E288
  816.                     dc.l     $66046100
  817.                     dc.l     $00A2653C
  818.                     dc.l     $72087601
  819.                     dc.l     $E2886604
  820.                     dc.l     $61000094
  821.                     dc.l     $655A7203
  822.                     dc.l     $42446100
  823.                     dc.l     $00963602
  824.                     dc.l     $D6447207
  825.                     dc.l     $E2886604
  826.                     dc.l     $6100007C
  827.                     dc.l     $E39251C9
  828.                     dc.l     $FFF41502
  829.                     dc.l     $51CBFFEC
  830.                     dc.l     $60000044
  831.                     dc.l     $72087808
  832.                     dc.l     $6000FFD8
  833.                     dc.l     $72026100
  834.                     dc.l     $006A0C02
  835.                     dc.l     $00026D16
  836.                     dc.l     $0C020003
  837.                     dc.l     $67E67208
  838.                     dc.l     $61000058
  839.                     dc.l     $3602323C
  840.                     dc.l     $000C6000
  841.                     dc.l     $000C323C
  842.                     dc.l     $0009D242
  843.                     dc.l     $54423602
  844.                     dc.l     $61000040
  845.                     dc.l     $534A14B2
  846.                     dc.l     $200051CB
  847.                     dc.l     $FFF833F9
  848.                     dc.l     $00DFFA06
  849. DecrColor           dc.l     $00DFF180        ; Flash screen
  850.                     dc.l     $B3CA6D00
  851.                     dc.l     $FF724EF9        ; jmp $address
  852. Reloc2              equ      *-Decruncher
  853.                     dc.l     $00123456
  854.                     dc.l     $303CFFFF
  855.                     dc.l     $33C000DF
  856.                     dc.l     $F18051C8
  857.                     dc.l     $FFF870FF
  858.                     dc.l     $4E752020
  859.                     dc.l     $B18544FC
  860.                     dc.l     $0010E290
  861.                     dc.l     $4E755341
  862.                     dc.l     $4242E288
  863.                     dc.l     $660A2020
  864.                     dc.l     $B18544FC
  865.                     dc.l     $0010E290
  866.                     dc.l     $E39251C9
  867.                     dc.l     $FFEE4E75
  868.                     dc.l     $E290E392
  869.  
  870. RelocBSSData        ; changed to Symbol table as these are ignored by dos
  871.                     dc.l     $000003f0        ; Reloc ? Why ? 0x3ec
  872.                     dc.l     0
  873.                     dc.l     $000003F2        ; End of hunk
  874.  
  875.                     dc.l     $000003f0        ; Bss ? Why ? 0x3eb
  876.                     dc.l     0
  877.                     dc.l     $000003F2        ; End of hunk
  878.  
  879. LengthBSS           equ      *-RelocBSSData
  880.  
  881. ActualLength        dc.l     0
  882. Buffer              dcb.l    14,0
  883. LengthToAlloc       dc.l     0
  884. AllocMem            dc.l     0
  885. FileBuffer          dc.l     0
  886. LocateAddr          dc.l     0
  887. JumpAddr            dc.l     0
  888. _OurLock            dc.l     0
  889. InitOutput          dc.l     0
  890. InitInput           dc.l     0
  891. DosBase             dc.l     0
  892. DosLibName          dc.b     'dos.library',0
  893. ConvertStr          dc.b     '0123456789abcdef'
  894. ScanWidth           dc.l     0
  895.  
  896.                     even
  897.  
  898. StartupText         dc.b     LF
  899.                     dc.b     ESC,'[3m'
  900.                     dc.b     'LORD BLITTER',$27,'S BYTEKILLER V1.3+',LF
  901.                     dc.b     'MODIFIED BY PSYCHO OF THE AWA. VERS 1.31  ',LF
  902.                     dc.b     'USER INTERFACE BY J.J.',$27,'87 of THE BLIZZARD  :  18.11.87',LF
  903.                     dc.b     ESC,'[2m'
  904.                     dc.b     'MODIFIED BY CATH OF THE FURY. VERS 2.03 : 20.07.92'
  905.                     dc.b     ESC,'[0m',LF
  906.                     length   StartupText
  907.  
  908. AllocateWork        dc.b     LF
  909.                     dc.b     'Allocate work space (KByte) :$'
  910.                     length   AllocateWork
  911.  
  912. FileOverrun         dc.b    LF
  913.                     dc.b    'Warning: File has overrun the allocated buffer, likely memory corruption'
  914.                     length   FileOverrun
  915.  
  916. LoadName            dc.b    LF
  917.                     dc.b    'Filename to load (exit to leave,'
  918.                     dc.b    ' -(command) to execute CLI command.)',LF
  919.                     dc.b    'Filename/Command :'
  920.                     length  LoadName
  921.  
  922. OriginalLength      dc.b    LF,'Original length :'
  923.                     length  OriginalLength
  924.  
  925. PackedLength        dc.b    LF,'Packed length :'
  926.                     length  PackedLength
  927.  
  928. SaveFileName        dc.b    LF,'Save Filename (exit to leave,'
  929.                     dc.b    ' -(command) to execute CLI command.)',LF
  930.                     dc.b    'Filename/Command :'
  931.                     length  SaveFileName
  932.  
  933. OffsetLength        dc.b    LF,'Scan Width (max $1000) :$'
  934.                     length  OffsetLength
  935.  
  936. ExecOrData          dc.b    LF,'Create executable file or data file ? (e/d) :'
  937.                     length  ExecOrData
  938.  
  939. LocateFileAt        dc.b    LF
  940.                     dc.b    'Locate file at :$'
  941.                     length  LocateFileAt
  942.  
  943. JumpInAddr          dc.b    LF
  944.                     dc.b    'Jump to address after DeCruncher :$'
  945.                     length  JumpInAddr
  946.  
  947. FlashType           dc.b    LF
  948.                     dc.b    '1-BackGround,2-Text,3-Sprite,4-Modulo'
  949.                     length  FlashType
  950.  
  951. FreeChipMem         dc.b    LF
  952.                     dc.b    'Largest block of chip memory available (KByte) :'
  953.                     length   FreeChipMem
  954.  
  955. FreeFastMem         dc.b   LF
  956.                     dc.b   'Largest block of fast memory available (KByte) :'
  957.                     length FreeFastMem
  958.  
  959. TypeOfMem           dc.b   LF
  960.                     dc.b   'Type of Memory at that address is :'
  961.                     length TypeOfMem
  962.  
  963. NoMemoryThere       dc.b   LF
  964.                     dc.b   'Warning: The address you specified is invalid and either has no',LF
  965.                     dc.b   'memory available there or is in ROM or is in the low memory area',LF
  966.                     length NoMemoryThere
  967.  
  968. IsChipMem           dc.b   'Chip memory',LF
  969.                     length IsChipMem
  970.  
  971. IsFastMem           dc.b   'Real Fast memory',LF
  972.                     length IsFastMem
  973.  
  974. IsFakeFastMem       dc.b   'Fake Fast memory',LF
  975.                     length IsFakeFastMem
  976.  
  977. Is24BitMem          dc.b   '24 bit DMA, '
  978.                     length Is24BitMem
  979.  
  980. IsLocalMem          dc.b   'Local, '
  981.                     length IsLocalMem
  982.  
  983. IsPublicMem         dc.b   'Public, '
  984.                     length IsPublicMem
  985.  
  986. WowWhatKindOfRam    dc.b   'What kind of RAM do you have ? 32 Bit ?'
  987.                     length WowWhatKindOfRam
  988.  
  989. Won                 dc.b   LF
  990.                     dc.b   'Bytes Saved :'
  991.                     length Won
  992.  
  993. Warning             dc.b   LF
  994.  dc.b '**********************************************************************',LF
  995.  dc.b '*  Warning: This appears to be a relocatable file and this version   *',LF
  996.  dc.b '*          of ByteKiller doesn',$27,'t handle relocs properly yet          *',LF
  997.  dc.b '**********************************************************************',LF
  998.                     length Warning
  999.  
  1000. FileNotFound        dc.b   LF
  1001.                     dc.b   'Couldn',$27,'t find that file !',LF
  1002.                     length FileNotFound
  1003.  
  1004. WantLongerFile      dc.b   LF,'File would be longer !',LF
  1005.                     length WantLongerFile
  1006.  
  1007. TooHigh             dc.b   LF,'Scan width is to high ($6-$1000)',LF
  1008.                     length TooHigh
  1009.  
  1010. FileTypeIs          dc.b   'File is a '
  1011.                     length FileTypeIs
  1012.  
  1013. WarnAlreadyPacked   dc.b   'ByteKiller 1.00-2.00 packed executable',LF
  1014.                     length WarnAlreadyPacked
  1015.  
  1016. PPDataFile          dc.b   'PowerPacker Data file'
  1017.                     length PPDataFile
  1018.  
  1019. STCDataFile         dc.b   'StoneCracker 401 Data file'
  1020.                     length STCDataFile
  1021.  
  1022. PackedPPLib         dc.b   'PowerPacker Exec + Library header'
  1023.                     length PackedPPLib
  1024.  
  1025. PackedPPExec        dc.b   'PowerPacker Executable'
  1026.                     length PackedPPExec
  1027.  
  1028. PackedImpLib        dc.b   'Imploder 4.0 Executable + Library decruncher'
  1029.                     length PackedImpLib
  1030.  
  1031. PackedImpExec       dc.b   'Imploder 4.0 Executable'
  1032.                     length PackedImpExec
  1033.  
  1034. IFFFile             dc.b   'IFF file'
  1035.                     length IFFFile
  1036.  
  1037. DeluxeEdBBLib       dc.b   'Deluxe Editor BB Library'
  1038.                     length DeluxeEdBBLib
  1039.  
  1040. LhaV5               dc.b   'Lharc Version 5'
  1041.                     length LhaV5
  1042.  
  1043. LhaV1               dc.b   'Lharc Version 1'
  1044.                     length LhaV1
  1045.  
  1046. InfoFileV1          dc.b   '.INFO file version 1'
  1047.                     length InfoFileV1
  1048.  
  1049. InterLeavedBitMap   dc.b   'IFF Interleaved Bitmap'
  1050.                     length InterLeavedBitMap
  1051.  
  1052. AnimFileBrush       dc.b   'IFF Anim or brush'
  1053.                     length AnimFileBrush
  1054.  
  1055. IffBrush            dc.b   'IFF Brush'
  1056.                     length IffBrush
  1057.  
  1058. PreferencesFile     dc.b   'Preferences File'
  1059.                     length PreferencesFile
  1060.  
  1061. Tetragon            dc.b   'Tetragon Cruncher'
  1062.                     length Tetragon
  1063.  
  1064. TucCruncher         dc.b   'Tuc-Cruncher'
  1065.                     length TucCruncher
  1066.  
  1067. ComPack             dc.b   'ComPack'
  1068.                     length ComPack
  1069.  
  1070. DoubleAction        dc.b   'Double action by Tristar',0
  1071.                     length DoubleAction
  1072.  
  1073. DefJam              dc.b   'DefJam Packer',0
  1074.                     length DefJam
  1075.  
  1076. ActionReplay        dc.b   'Action Replay file',0
  1077.                     length ActionReplay
  1078.  
  1079. NormalOrUnknown     dc.b   'Normal executable or unknown cruncher'
  1080.                     length NormalOrUnknown
  1081.  
  1082. DataAbsFile         dc.b   'Data file or absolute'
  1083.                     length DataAbsFile
  1084.  
  1085. FileLonger          dc.b   LF,'File longer than original',LF
  1086.                     length FileLonger
  1087.  
  1088. FileHeadLonger      dc.b   LF,'File + Header longer than original !',LF
  1089.                     length FileHeadLonger
  1090.  
  1091. _DOSBase            equ     DosBase          ; for system compatibility
  1092.  
  1093. FlashTable          dc.b    $00,$0
  1094.  ; Recognised file types ( most of them are accurate )
  1095.  
  1096.                     cnop   0,4
  1097. WhatIs
  1098.                     dc.w   $24                                  ; Offset
  1099.                     dc.l   $41fa00e6                            ; check value
  1100.                     ptr    WarnAlreadyPacked                    ; Text,length
  1101.                     dc.w   $60
  1102.                     dc.l   $66ea6130
  1103.                     ptr    PackedImpExec
  1104.                     dc.w   $60
  1105.                     dc.l   $72790020
  1106.                     ptr    PackedImpLib
  1107.                     dc.w   $34
  1108.                     dc.l   $d1c85848
  1109.                     ptr    PackedPPExec
  1110.                     dc.w   $38
  1111.                     dc.l   $fdd84a80
  1112.                     ptr    PackedPPLib
  1113.                     dc.w   0
  1114.                     dc.l   'S401'
  1115.                     ptr    STCDataFile
  1116.                     dc.w   0
  1117.                     dc.l   'PP20'
  1118.                     ptr    PPDataFile
  1119.                     dc.w   4
  1120.                     dc.l   ': De'
  1121.                     ptr    DeluxeEdBBLib
  1122.                     dc.w   4
  1123.                     dc.l   $68352de9
  1124.                     ptr    LhaV5
  1125.                     dc.w   4
  1126.                     dc.l   $68312d31
  1127.                     ptr    LhaV1
  1128.                     dc.w   0
  1129.                     dc.l   $E3100001
  1130.                     ptr    InfoFileV1
  1131.                     dc.w   8
  1132.                     dc.l   'PREF'
  1133.                     ptr    PreferencesFile
  1134.                     dc.w   $60
  1135.                     dc.l   'GRAB'
  1136.                     ptr    IffBrush
  1137.                     dc.w   8
  1138.                     dc.l   'ANIM'
  1139.                     ptr    AnimFileBrush
  1140.                     dc.w   8
  1141.                     dc.l   'ILBM'
  1142.                     ptr    InterLeavedBitMap
  1143.                     dc.w   -2            ; Search first $150 bytes
  1144.                     dc.l   'GON '
  1145.                     ptr    Tetragon
  1146.                     dc.w   $44
  1147.                     dc.l   'rich'
  1148.                     ptr    TucCruncher
  1149.                     dc.w   0
  1150.                     dc.l   $504
  1151.                     ptr    ComPack
  1152.                     dc.w   $80
  1153.                     dc.l   'Doub'
  1154.                     ptr    DoubleAction
  1155.                     dc.w   0
  1156.                     dc.l   'ARPF'
  1157.                     ptr    ActionReplay
  1158.                     dc.w   0
  1159.                     dc.l   'FORM'
  1160.                     ptr    IFFFile
  1161.                     dc.w   $178
  1162.                     dc.l   'JAM '
  1163.                     ptr    DefJam
  1164.                     dc.w   0
  1165.                     dc.l   $3f3
  1166.                     ptr    NormalOrUnknown
  1167.                     dc.w   -1                     ; end of list
  1168.                     dc.l   0
  1169.                     dc.l   0
  1170.  
  1171.            *--------------------------------------------------*
  1172.             dc.b "$VER: ByteKiller Two by Cath of Fury 1992",0
  1173.            *--------------------------------------------------*
  1174.  
  1175.                     END
  1176. ;END